package com.dashu.base.Log;


public class Logger {

    private org.apache.log4j.Logger logger;

    public Logger(Class cls) {
        logger = org.apache.log4j.Logger.getLogger(cls);
    }

    /**
     * 打印错误日志
     *
     * @param o
     */
    public void error(Object o) {
        logger.error(o);
        System.out.println(o.toString());
    }

    /**
     * 打印错误日志
     *
     * @param o
     * @param e
     */
    public void error(Object o, Throwable e) {
        logger.error(o, e);
        System.out.println(o + ":" + e);
    }

    /**
     * 打印错误日志
     *
     * @param o
     * @param e
     */
    public void error(Object o, Throwable e , boolean... isDebug) {
        if (isDebug != null && isDebug.length > 0 && isDebug[0]) {
            logger.error(o, e);
            System.out.println(o + ":" + e);
        }
    }

    /**
     * 打印错误日志
     *
     * @param o
     * @param isPrint true 打印   false 不打印
     */
    public void error(Object o, boolean isPrint) {
        logger.error(o);
        if (!isPrint)
            System.out.println(o);
    }

    /**
     * 打印错误日志
     *
     * @param o
     * @param isPrint true 打印   false 不打印
     */
    public void error(Object o, Throwable e, boolean isPrint) {
        logger.error(o, e);
        if (!isPrint)
            System.out.println(o + ":" + e);
    }


    public void info(Object o) {
        logger.info(o);
        System.out.println(o);
    }


    public void info(Object o,boolean... isDebug) {
        if (isDebug != null && isDebug.length > 0 && isDebug[0]) {
            logger.info(o);
            System.out.println(o);
        }
    }

    public void info(Object o, Throwable e) {
        logger.info(o, e);
        System.out.println(o + ":" + e);
    }


//    public void info(Object o, boolean isPrint) {
//        logger.info(o);
//        if (!isPrint)
//            System.out.println(o);
//    }

    public void info(Object o, Throwable e, boolean isPrint) {
        logger.info(o, e);
        if (!isPrint)
            System.out.println(o + ":" + e);
    }

    public void debug(Object o) {
        logger.debug(o);
        System.out.println(o);
    }

    public void debug(Object o, Throwable e) {
        logger.debug(o, e);
        System.out.println(o + ":" + e);
    }


    public void debug(Object o, boolean isPrint) {
        logger.debug(o);
        if (!isPrint)
            System.out.println(o);
    }

    public void debug(Object o, Throwable e, boolean isPrint) {
        logger.debug(o, e);
        if (!isPrint)
            System.out.println(o + ":" + e);
    }

}
